<template>
  <view>
    <image src="../../static/logo-1.png" class="logo" mode="widthFix"></image>
    <view class="logo-title">EMOS在线办公系统</view>
    <view class="logo-subTitle">Ver 2050.2</view>
    <button class="login-btn" @tap="login()" open-type="getUserInfo">登陆系统</button>
    <view class="register-container">
      没有帐号?
      <text class="register" @tap="toRegister()">立即注册</text>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {};
    },
    methods: {
      toRegister: function() {
      uni.navigateTo({
        url: "/pages/register/register"
		});
	  },
	  login: function() {
		let that = this;
		console.log("111");
	  	uni.login({
	  		provider: "weixin",
	  		success: function(resp) {
				let code = resp.code;
	  			let data = {code: code}
	  			that.$ajax(that.$url.login, "post", data, function(resp) {
	  				let permission = resp.data.permission;
					uni.setStorageSync("permission", permission);
					// 跳转到登陆页面
					console.log("可以准备跳转");
					uni.switchTab({
						url: "../index/index"
					});
	  			});
	  		},
			fail:function(e){
				uni.showToast({
					icon:"none",
					title:"执行异常"
				})
			}
	  	});	  
	  }
    }
  };
</script>

<style lang="less">
@import url("login.less");
</style>